﻿using System;
using TechTalk.SpecFlow;
using WatiN.Core;

namespace Testicide_BDD.Steps
{
    [Binding]
    public class ManagingFeaturesSteps
    {
        private IE _browser;
        public ManagingFeaturesSteps()
        {
            _browser = new IE();
        }

                [Given(@"I am on the Details page of Module number (.*)")]
        public void GivenIAmOnTheDetailsPageOfModuleNumber(int p0)
        {
            _browser.GoTo("http://localhost:57662/Module/Details/" + p0);
        }

                [When(@"I press Add new Feature")]
        public void WhenIPressAddNewFeature()
        {
            var link = _browser.Link("addNewFeature");
            link.Click();
        }

                [When(@"I fill in Feature's name with ""(.*)""")]
        public void WhenIFillInFeatureSNameWith(string p0)
        {
            var text = _browser.TextField("Name");
            text.TypeText(p0);
        }

                [When(@"I press Create Feature")]
        public void WhenIPressCreateFeature()
        {
            var button = _browser.Button("Create");
            button.Click();
        }

                [When(@"I click edit feature number (.*)")]
        public void WhenIClickEditFeatureNumber(int p0)
        {
            var link = _browser.Link("editFeature_"+p0);
            link.Click();
        }

                [When(@"I press Edit Feature")]
        public void WhenIPressEditFeature()
        {
            var button = _browser.Button("Edit");
            button.Click();
        }

                [When(@"I click delete feature number (.*)")]
        public void WhenIClickDeleteFeatureNumber(int p0)
        {
            var link = _browser.Link("deleteFeature_" + p0);
            link.Click();
        }

                [When(@"I press Delete Feature")]
        public void WhenIPressDeleteFeature()
        {
            var button = _browser.Button("Delete");
            button.Click();
        }

                [When(@"I click on feature number (.*)")]
        public void WhenIClickOnFeatureNumber(int p0)
        {
            var link = _browser.Link("detailsFeature_" + p0);
            link.Click();
        }

                [Then(@"I should see the feature ""(.*)""")]
        public void ThenIShouldSeeTheFeature(string p0)
        {
            _browser.ContainsText(p0);
        }

                [Then(@"I should see the feature ""(.*)"" in the features of Module (.*)")]
        public void ThenIShouldSeeTheFeatureInTheFeaturesOfModule(string p0, int p1)
        {
            _browser.GoTo("http://localhost:57662/Module/Details/" + p1);
            _browser.ContainsText(p0);
        }

                [Then(@"I shouldn't see the feature ""(.*)"" in the features of Module (.*)")]
        public void ThenIShouldnTSeeTheFeatureInTheFeaturesOfModule(string p0, int p1)
        {
            _browser.GoTo("http://localhost:57662/Module/Details/" + p1);
            bool x = !_browser.ContainsText(p0);
        }

                [Then(@"I should see the Scenarios contents ""(.*)""")]
        public void ThenIShouldSeeTheScenariosContents(string p0)
        {
            _browser.ContainsText(p0);
        }

        [AfterScenario]
        public void xxx()
        {
            _browser.Dispose();
        }
    }
}
